<?php
/**
 * Users controller class
 */
class Location_MaterielInformatiqueController extends Zend_Controller_Action
{
	
	public function init()
	{
		Zend_View_Helper_PaginationControl::setDefaultViewPartial('controls.phtml');
		$this->view->layout()->title = $this->_getParam('t','Location ordinateurs portables à marseille');
	}
	/**
	 * page d'accueil  : view all categories
	 */
	public function indexAction()
	{
		$cat = new Location_Model_Category();
		$this->view->categories = $cat->fetchParentCategories();
	}

	/**
	 * Liste des mat�riels d'une cat�gorie choisie
	 * @return unknown_type
	 */
	public function listAction()
	{
		
		$materiels = new Location_Model_Materiel();
		
		$paginator = Zend_Paginator::factory($materiels->fetchAllByCategoryId($this->_getParam('categoryid')));
		$paginator->setCurrentPageNumber($this->_getParam('page', 1));
		$paginator->setItemCountPerPage(2);		
		$this->view->paginator = $paginator;
	}
	
	public function packAction()
	{
		$packInstance = new Location_Model_PackInstance();
		
		$paginator = Zend_Paginator::factory($packInstance->fetchByPackId($this->_getParam('packid')));
		$paginator->setCurrentPageNumber($this->_getParam('page', 1));
		$paginator->setItemCountPerPage(2);		
		$this->view->paginator = $paginator;
	}

	/**
	 * Détail sur un matériel choisi
	 */
	public function infoAction()
	{
		$materiels = new Location_Model_Materiel();
		$this->view->materiel = $materiels->fetchById($this->_getParam('materielid'));
	}

	/**
	 * D�tail sur un ensemble choisi
	 */
	public function infoPackAction()
	{

	}
}
